'''
词云分许
'''
from wordcloud import WordCloud
import matplotlib.pyplot as plt
import json,re

List=[]
for vol_num in range(1,45):
    filename="OL_VOL{}.json".format(vol_num)
    with open(filename,encoding='utf-8') as obj:
        articles=json.load(obj)
    for article in articles:
        title=re.sub('\n|\r|\t','',article['title'],flags=re.IGNORECASE)#简单去除文本内`\n\t\r`等标记。
        List.append(title)
        
title_all=[str(i) for i in List]
title_alls=''.join(title_all)

wordcloud=WordCloud(width=800*4, height=600*4, mode='RGBA', background_color=None).generate(title_alls)
# 生成词云

plt.imshow(wordcloud,interpolation='bilinear')
plt.axis("off")
wordcloud.to_file('OL_title.png')
# plt.show()

